<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
${pu:reqSet('user', pu:user())}
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="<%=application.getContextPath() %>/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="<%=application.getContextPath() %>/js/jquery.datepick-zh-CN.js"></script>
<script src="<%=application.getContextPath() %>/js/jquery.tooltip.js" type="text/javascript"></script>

<link rel="stylesheet" href="<%=application.getContextPath() %>/css/jquery.tooltip.css" />
<link rel="stylesheet" type="text/css" href="<%=application.getContextPath() %>/css/smoothness.datepick.css" />
<link rel="stylesheet" type="text/css" href="<%=application.getContextPath() %>/css/validator.css" />
<script language="javascript">
	$().ready( function() {
		
		$('#startDtParam').datepick({dateFormat:"yy-mm-dd"}); 
		
		$("#queryOrder").click(function(){
			$("#orderQuery").attr("action","query.do");
			$("#orderQuery").submit();
		});
		

		
	});
function tuangouProcess(type,tid){
	var url;
	if(type=='S'){//结团
		url="<c-rt:url value="/tuangou/tuangouSuccess.do"/>";
	}else if(type=='F'){//流团
		url="<c-rt:url value="/tuangou/tuangouFail.do"/>";
	}
	$.post(url,{tuangouId:tid},
		function(result){
		if(result=='"true"'){
			alert("处理成功");
			$("#orderQuery").submit();
		}
		});
			
}	
</script>
<s:actionerror />
<s:actionmessage />
<s:fielderror />
<br />
<h1>团购订单核单</h1>
<div class="f-link">
</div>
<br /><br /><br />
<div class="data-form"><s:form action="query.do" method="post" id="orderQuery">
	<b>团购编号：</b>
	<input name="tuangouIdParam" type="text" id="tuangouIdParam" value="${tuangouIdParam}" size="20" maxlength="20">	
	<b>商品编号：</b>
	<input type="text" name="prodIdParam" id="prodIdParam" value="${prodIdParam }" size="10" maxlength="8"/>
	<b>活动起始日期：</b>
	<input name="startDtParam" type="text" id="startDtParam" value="${startDtParam}" size="10" maxlength="10">   
	<br>
	<b>商品名称：</b>
	<input type="text" name="prodNmParam" id="prodNmParam" value="${prodNmParam }" size="50"/>
	<input type="button" value="搜寻" id="queryOrder" />	
</s:form>
</div>
<br/><br/><br/>
<s:if test="tuangous.size > 0">
	<yaodian100:pageutil link="query.do" pagerObj="${pager}" />
	<table class="tb-1" width="100%"  >
		<thead>
			<tr>
				<th>团购</th>
				<th>商品名称</th>
				<th>活动日期</th>
				<th>活动最低订购人数</th>
				<th>售价</th>
				<th>订购数量</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${tuangous}" var="tuangou" varStatus="rows_index">
				<tr class="">
					<td>${tuangou.tuangouId }</td>
					<td class="al-lf"><span title="${tuangou.promoteName}"  class="tg-name">${tuangou.promoteName}</span><br>${productNames[tuangou.productId] }</td>
					
					<td><fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${tuangou.startDate }" /> ~ <fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${tuangou.endDate }" /></td>
					<td>${tuangou.lowestOrderQty }</td>
					<td><fmt:formatNumber value="${tuangou.price }" pattern="#,###,##0.0"/></td>
					<td>${tuangou.orderQty-tuangou.cancelQty }</td>
					<td>					
					<c-rt:if test="${tuangou.tuangouStatus=='0'}">
					<a href="javascript:tuangouProcess('S','${tuangou.tuangouId }')">团购成立同步订单</a><BR>
					<a href="javascript:tuangouProcess('F','${tuangou.tuangouId }')">团购流团取消订单</a>
					</c-rt:if>
					</td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<yaodian100:pageutil link="query.do" pagerObj="${pager}" />
</s:if>
<br /><br /><br />
